import Taro, { Component } from '@tarojs/taro';
import { View, Image, Button } from '@tarojs/components';

import NavigationBar from '../../components/navigationBar/index';
import { canEatFinsh } from '../../services/user';
import { fullImgUrl } from '../../utils/utils';
import './index.scss';
export default class Index extends Component {
  config = {
    navigationBarTitleText: '',
  };

  state = {
    status: '',
    navigationBarHeight: Taro.getStorageSync('navigationBarHeight'),
  };

  componentWillMount() {}
  componentDidMount() {
    // getUserInfo({id:Taro.getStorageSync('userInfo')}).then(res => {
    //     console.log(res,'eeee')
    // })
    // if (!Taro.getStorageSync('userInfo')) {
    //   Taro.navigateTo({
    //     url: '/subPackageWork/pages/login/index',
    //   });
    // }else{
    // }
  }
  componentWillReceiveProps(nextProps, nextContext) {}
  componentWillUnmount() {}
  componentDidShow() {
    canEatFinsh().then(res => {
      this.setState({
        status: res,
      });
    });
  }
  componentDidHide() {}
  componentDidCatchError() {}
  componentDidNotFound() {}

  render() {
    const { status } = this.state;
    return (
      <View className='home' style={`margin-top: ${navigationBarHeight}`}>
        <NavigationBar text='活动页' type="activity"/>
        <View className='active-wrapper'>
          {(status || status === 0) &&
            (status ? (
              <Image src={fullImgUrl('success.jpg')} mode='aspectFill' className='active-img' />
            ) : (
              <Image src={fullImgUrl('fail.jpg')} mode='aspectFill' className='active-img' />
            ))}
        </View>
      </View>
    );
  }
}
